package ttt;
public class Point {
	
	private int row, col;
	
	public Point(int x, int y) {
		row = x;
		col = y;
	}
	
	public int getRow() {
		return row;
	}
	
	public int getColumn() {
		return col;
	}
	
	public static int pointToIndex(Point point) {
		if(point == null)
			return -1;
		
		return point.row*3 + point.col;
	}
	
	public static Point indexToPoint(int index) {
		int col = index % 3;
		int row = index / 3;
		
		return new Point(row, col);
	}
	
	public String toString() {
		return "(" + row + ", " + col + ")";
	}
}
